<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="goto()">百度</button>
    <script>
        console.log(window.location);
        // 协议   主机地址   端口 路径              参数
        // http://127.0.0.1:5500/BOM/location.html?id=123
        // location 代表浏览器上当前链接的url信息
        // 获取当前url
        console.log(location.href,'完整的url');
        // 获取协议
        console.log(location.protocol,'协议');
        // 获取主机地址
        console.log(location.host,'主机地址');
         // 获取主机地址
        console.log(location.hostname,'主机地址没有端口');
         // 获取端口
         console.log(location.port,'端口');
        //  获取路径
        console.log(location.pathname,'获取路径');
        // 获取参数
        console.log(location.search,'获取参数');
        
        
        function goto(){
            // 基于location 进行网页跳转
            location.href = 'http://127.0.0.1:5500/BOM/history.html'

        }

        
    </script>
</body>
</html>